import axios from "axios"


const instance = axios.create({
    // baseURL: 'http://rank.jasonandjay.com',
    // baseURL: window.location.host==='123.206.55.50'?'http://rank.jasonandjay.com':'http://47.92.71.239',
    // 通过host动态判断baseURL
    // baseURL: window.location.host==='123.206.55.50'?'http://rank.jasonandjay.com':'',
    // 通过环境变量动态判断baseURL, process.env.NODE_ENV
    baseURL: process.env.NODE_ENV==='production'?'//rank.jasonandjay.com':'',
    timeout: 30000,
});
//请求拦截器
instance.interceptors.request.use(function (config) {
    // Do something before request is sent
    return config;
}, function (error) {
    // Do something with request error
    return Promise.reject(error);
});
//相应拦截器
instance.interceptors.response.use(function (response) {
    // Do something with response data
    return response;
}, function (error) {
    // Do something with response error
    return Promise.reject(error);
});

export default instance